package lab02.test24;

/**
 * Created by admin on 2017/10/31.
 */
import java.text.SimpleDateFormat;
import java.util.*;
public class Test {
    public static void main(String[] args) {
        SimpleDateFormat dateFormat=new SimpleDateFormat("yyyy年MM月dd日");
        System.out.println("请输入第一个日期，格式如20100310:");
        Scanner scanner=new Scanner(System.in);
        int s1,year1,month1,day1;
        s1=scanner.nextInt();
        year1=s1/10000;
        s1=s1/1000;
        month1=s1/100;
        day1=s1/10;
        Calendar calendar1=Calendar.getInstance();
        calendar1.set(year1,month1-1,day1);
        Date date1=calendar1.getTime();
        System.out.println("请输入第二个日期，格式如20100310:");
        int s2,year2,month2,day2;
        s2=scanner.nextInt();
        year2=s2/10000;
        s2=s2/1000;
        month2=s2/100;
        day2=s2/10;
        Calendar calendar2=Calendar.getInstance();
        calendar2.set(year2,month2-1,day2);
        Date date2=calendar2.getTime();
        long countDay=(date2.getTime()-date1.getTime())/24*60*60*1000;
        System.out.println("两个日期之间相差"+countDay+"天");
    }
}
